// document.write("new a model!")
// $.get("",function(){
//     console.log(data);
//     var myChart = echarts.init(document.getElementById("main"));
//     var option = {
//         series:[
//         {    
//           type:"pie",
//             data:[1,2,3],
//         data:data.data_pie,
//         },
//       ],
//     };
//     myChart.setOption(option);
// });
$.get("../work.csv",function(data){
  //先按照换行分开字符串；
  data = data.split('\r\n');
  // console.log(data.length);
  var new_data=[];
  for(var i=0;i<data.length;i++){
    // console.log(data[i]);
    //再根据逗号分开字符串
    var temp = data[i].split(",");
    // console.log(temp);
    new_data.push(temp);
  }
  // console.log(new_data);
  console.log(new_data[0]);
  console.log(new_data[1]);
  
  var value_show=[];
  var name_company=[];
  var name2_company=[];
  for(var i=1;i<new_data.length;i++){
      value_show.push(new_data[i][2]);
      name_company.push(new_data[i][0]);
      name2_company.push(new_data[i][6]);
  }
  // 基于准备好的dom，初始化echarts实例；
  var myChart = echarts.init(document.getElementById("main"));
  //画图配置
  option = {
    
      xAxis: {
          type: 'category',
          data: name_company,
          name: new_data[0][0],        
      },
      yAxis:[ {
          name: new_data[0][2],
      },
      {
        name: new_data[0][6],
    }],
      series: [
          {
              name: '待遇',
              type: 'line',
              data: value_show,
              yAxisIndex: 0,
          },
          {
            name: '人数',
            type: 'bar',
            data: name2_company,
            yAxisIndex: 1,
        },
      ],
      grid: [{
        right: '13%',
        left: '17%',
    }],
        xAxis: [{
            type: 'category',
            gridIndex: 0,
            data: name_company,
            name: new_data[0][0],        
        }],
        yAxis: [{
            gridIndex: 0,
            name: new_data[0][2],
            min:0,
            max:22500,
            },
            {
                gridIndex: 0,
                name: new_data[0][6],
                min:0,
                max:100,
            },
        ],
        legend: {
          right: '7%'
      },
      title: {
          text: '就业调查',
          left: 'center',
      },
        dataZoom: [
          {
              type:'slider',
              backgroundColor: 'white',
              dataBackground: {
                  areaStyle: {
                      color: 'white',
                      opacity: 1,
                  },
                  lineStyle: {
                      color: 'black',
                  },
              },
              selectedDataBackground:{
                  areaStyle: {
                      color: 'yellow',
                      opacity: 1,
                  },
              }

          },{
              type:'inside'
          }
      ],
  };

  // //使用刚配置的数据和配置项来生成图表；
  myChart.setOption(option);
})